Refactor library architecture#19
Merged
Merged
Conversation
LesterEvSe
marked this pull request as ready for review
June 30, 2026 11:36
Hrom131
reviewed
Jul 1, 2026
Hrom131
reviewed
Jul 1, 2026
Hrom131
reviewed
Jul 1, 2026
Arvolear
added a commit
that referenced
this pull request
Jul 24, 2026
* Initial version (#8) * added simplex template * added assert functions with test * documented functions in asserts file * added todo comment * updated simplex version to 0.0.5 * Example of a test with the unhappy path (#9) * updated test with negative path for asserts * fixed typo * added helper function to mock; fixed typo * added more specific error check * Updated smplx version (#12) * updated minimal simplex version to 0.0.6 * fixed test command in ci * Asserts function refactoring (#11) * renamed asserts functions to be more consistent; removed unsuported "pub" modifier * made asserts test more detailed; added random generation of test data * added logical operations (#13) * Added safe uint functions (#14) * added safe functions for u8, u16, u32, u64 * added mocks and tests for uints * fixed incorrect names in tests * fixed import order in tests * linting * refactored error assertion in tests * Updated readme (#15) * updated readme * added instructions for smplx installation * Feat/modules (#17) * updated contracts to use modules and imports * updated u8, u16, u32 and u64 contracts to use modules and imports * fixing ci by using smplx from specific commit * trying to fix ci * updated readme * Refactor library architecture (#19) * feat: recode `uint` operations for clarity * feat: refactor `asserts_test.rs` and `README.md` a bit * refactor: docstring a little bit more * update: version of Simplex to `0.0.7` * refactor: docstring for macros and simf code a bit * Add uint128 (#21) * added functions for u128; added assert_eq_128 * added test for assert_eq_128 * updated simplex version * fixed typo * fixed typo * optimized mul_128; removed temporary helper * divided tests for uint128 to speed up github ci * trying to optimize ci by running simplex tests on multiple threads * removed unused witness * refactored index in tests; splitted test by module * optimized u128 * added check for randomized inputs in tests * added more test cases for sub128 * refactored and optimized tests * added a fex test cases for div_mod_128 * refactored tests for left and right shift * Add gt ge functions for uints (#23) * added gt and ge operators * removed unnecessary pub modifier * renamed assert_bool to prevent future collisions * added gt and ge operators for u128 * Add functions for op_return (#22) * added functions for op_return; added run_with_op_return to helpers * fixed todo * added documentation for op_return functions * Feat/get ready for release (#24) * uodated readme * updated Cargo.toml * Helper functions for future confidential transactions on secp256k1 (#28) * feat: add `u64_widen` helper function * feat: add ec operations and test them, add asserts for u1 * refactor: delete unused file * refactor(u64): restore gt and ge in u64_test.simf * refactor: naming for elliptic curve operations * refactor: rename u64_widen into u64_into_u256 and fix test case * refactor: rename the test * update: add secp256k1 operations to README file * Fix/pre-release (#29) * renamed logical_operations to boolean; added xor * linting * added todo comment * renamed boolean file to binary * cleanup --------- Co-authored-by: Yuliia Aritkulova <94910987+aritkulova@users.noreply.github.com> Co-authored-by: Yevhenii Sekhin <evgenii.nikolaevichfgh@gmail.com> Co-authored-by: Artem Chystiakov <artem.ch31@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor the standard library and test suite
Resolves #18 for current state.
Reorganises the standard library into three conceptual parts and rewrites the
Rust test suite to eliminate duplicated boilerplate.
1.
simf/lib/— the library itselfThe standard-library functions. Unchanged in this PR; only the surrounding
scaffolding (parts 2 and 3) is touched.
2.
simf/—main-function contractsThe test entry-point contracts, one
mainper area. Cleaned up with a clearerstructure and a shared helper.
*_mock.simf→*_test.simf: these are test entry points, not mocks.IF_TEST_OVERFLOWwitness flag. The overflow vs. fitting caseis now encoded in the data: a
checked_*result is compared against anexpected: Option<T>witness, whereNonemeans overflow andSome(x)thefitting result. This drops one
matchlevel and one witness field from everycontract.
3.
tests/— the Rust test suiteRewritten. Previously,
fund_script/spend_scriptand the spend-and-assertlogic were duplicated in every file, and
u8_test.rsthroughu64_test.rswerenear-identical, differing only by type.
Shared spend plumbing —
tests/common/mod.rsUsed by every test:
fund— send sats to a program's script so it has a UTXO to spend.spend— build the transaction with a witness and broadcast it.run— fund + spend + assert in one call.Expect— the expected outcome of a spend.uint test framework —
tests/common/uint.rsCovers operations uniform across every unsigned width (
safe_add_N,checked_mul_N, etc.). Built on aTestUinttrait: each operation's logic iswritten once as a generic function and instantiated per width. The only
per-width code is a short
impl TestUintblock.Type-specific operations
Operations that exist for only one width are not forced into the common
interface. Dispatch indices leave room for them:
0..=191— reserved for common operations.CUSTOM_BASE = 192— start of type-specific operations.A future
u64_widen(...) -> u256, for example, adds amatcharm atfn_idx == 192inu64_test.rswithout touching the shared interface.